<template>
    <div class="home">
        <div class="home-top">
            <div class="home-avatar">
                <img :src="busInfo.linkmanAvatar" alt="">
            </div>
            <div class="home-top-des">
                <div class="title">{{ busInfo.linkman }}，你好</div>
                <div class="des">本月您已累计为{{ busInfo.currMonthPrintedCount }}位朋友送上了一张特别贺卡</div>
            </div>
        </div>
        <div class="home-bottom">
            <div class="title">
                我的工作台
            </div>
            <div class="item-list">
                <div class="item">
                    <h1>{{ busInfo.pendingCount }}</h1>
                    <p>待处理贺卡订单</p>
                </div>
                <div class="item">
                    <h1>{{ busInfo.printableCount }}</h1>
                    <p>打印贺卡余量</p>
                </div>
            </div>
            <div class="submit-btn-box">
                <div class="submit-btn" @click="handleTo">贺卡充值</div>
            </div>
        </div>
    </div>
</template>

<script>
import { homeRequest } from "@/api";

export default {
    name: "tarbarHomeIndex",
    data() {
        return {
            busInfo: {
                linkmanAvatar: '',
                linkman: '',
                pendingCount: '-',
                printableCount: '-',
                currMonthPrintedCount: '-'
            }
        }
    },
    onShow() {
        homeRequest.workDashboard().then(res => {
            this.busInfo = res.data
        })
    },
    methods: {
        handleTo() {
            uni.navigateTo({
                url: '/pages/pay/index'
            })
        }
    }
}
</script>

<style lang="less">
.home {
    height: 100vh;
    padding: 16px;
    overflow: hidden;
    background-color: #FBFBFB;
    .home-top,
    .home-bottom{
        background-color: #FFFFFF;
        border-radius: 8px;
        width: 100%;
        min-height: 100px;
        padding: 16px;
        display: flex;
        margin-bottom: 8px;
    }
    .home-avatar {
        width: 48px;
        height: 48px;
        border-radius: 4px;
        background-color: #FBFBFB;
        margin-right: 16px;
    }
    .home-top-des {
        .title {
            font-size: 16px;
            color: #000;
            margin-bottom: 20px;
        }
        .des {
            font-size: 12px;
            color: #999999;
            line-height: 16px;
        }
    }
    .home-bottom {
        flex-direction: column;
        .title {
            font-size: 14px;
            color: #8f8f94;
            margin-bottom: 60px;
        }
        .item-list {
            display: flex;
            justify-content: space-between;
            padding: 0 10px;
            margin-bottom: 60px;
            text-align: center;
            h1 {
                font-size: 16px;
                font-weight: bold;
                margin-bottom: 10px;
            }
            p {
                font-size: 14px;
                color: #999999;
            }
        }
        .submit-btn-box {
            display: flex;
            justify-content: center;
            align-items: center;
            padding: 0 10px;
    
            .submit-btn {
                width: 100%;
                height: 40px;
                line-height: 40px;
                font-size: 14px;
                text-align: center;
                color: #FFFFFF;
                background-color: #5581FA;
                border-radius: 6px;
            }
        }
    }
}
</style>